package com.yansu.own.controller;

import com.yansu.own.common.dtos.ResponseResult;
import com.yansu.own.entity.dto.SysMaterialDto;
import com.yansu.own.entity.pojo.SysMaterial;
import com.yansu.own.service.SysMaterialService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * 素材接口
 */
@Slf4j
@RestController
@RequestMapping("/sysMaterial")
@Api(value = "素材管理",tags = "素材管理",description = "素材管理api")
public class SysMaterialController {
    @Autowired
    private SysMaterialService materialService;

    /**
     * 上传图片素材
     */
    @ApiOperation("上传图片素材")
    @PostMapping("/uploadPicture")
    public ResponseResult<SysMaterial> uploadPicture(@ApiParam("图片文件") MultipartFile multipartFile){
        return materialService.uploadPicture(multipartFile);
    }

    /**
     * 查看素材列表
     */
    @ApiOperation("查看素材列表")
    @PostMapping("/list")
    public ResponseResult<List<SysMaterial>> materialList(@RequestBody SysMaterialDto dto){
        return materialService.materialList(dto);
    }
}
